<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" type="text/css" href="/Blog/Public/css/bootstrap.min.css" />
		<title></title>
	</head>

	<body>
		<div class="container-fluid">
			<div class="row">
				<div class="col-md-12">
					<h2>分类管理</h2>
					<hr />
					<div class="alert alert-warning" role="alert" id="alertMsg" style="display: none;"></div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-3 col-md-offset-1">
					<h3>添加分类</h3>
					<form action="javascript:;" id="category_form">
						<div class="form-group">
							<label for="InputCategory">分类名</label>
							<input type="text" class="form-control" name="category_name" id="InputCategory" placeholder="分类名" required>
							<small style="color:#888888;">
								文章分类的名称
							</small>
						</div>
						<div class="form-group">
							<label for="InputFather">父类</label>
							<br />
							<select name="category_pid" class="form-control">
								<option value="0">顶级分类</option>
								<?php if(is_array($trees)): foreach($trees as $key=>$tree): ?><option value="<?php echo ($tree["category_id"]); ?>"><?php echo ($tree["_name"]); ?></option><?php endforeach; endif; ?>
							</select>
							<small style="color:#888888;">
								指定当前分类的父级分类
							</small>
						</div>

						<button type="submit" class="btn btn-primary" id="addCategoryBtn"><span class="glyphicon glyphicon-plus"></span>添加分类</button>
					</form>

				</div>
				<div class="col-md-7 ">
					<div class="col-md-6">
						<h3>分类信息</h3></div>
					<div class="col-md-6">
						<form class="form-inline" action="javascript:;" id="search_category" style="margin-top:15px;text-align: right;">
							<div class="form-group">
								<label class="sr-only" for="exampleInputEmail3"></label>
								<input type="text" class="form-control" id="c_name" placeholder="分类名">
							</div>

							<button type="submit" id="c_sub" class="btn btn-default"><span class="glyphicon glyphicon-zoom-in"></span>搜索分类</button>
						</form>
					</div>
					<table class="table table-hover" id="category_table" style="border:1px solid #DDDDDD;">
						<tr class="active">
							<th>ID</th>
							<th>分类名</th>
							<th>文章数量</th>
							<th>操作</th>
						</tr>
						<?php if(is_array($trees)): foreach($trees as $key=>$category): ?><tr data-cid="<?php echo ($category["category_id"]); ?>" data-pid="<?php echo ($category["category_pid"]); ?>" data-data="<?php echo ($category["category_id"]); ?>|<?php echo ($category["category_name"]); ?>|<?php echo ($category["category_pid"]); ?>">
								<td><?php echo ($category["category_id"]); ?></td>
								<td><a href=""><?php echo ($category["_name"]); ?></a></td>
								<td><?php echo ($category["count"]); ?></td>
								<td class="editBtnBox">
									<a href="javascript:;" class="btn btn-xs btn-success editBtn"><span class="glyphicon glyphicon-pencil"></span>编辑</a>
									<a href="javascript:;" class="btn btn-xs btn-danger delBtn"><span class="glyphicon glyphicon-trash">删除</a>
									<a href="javascript:;" class="btn btn-xs btn-info showBtn"><span class="glyphicon glyphicon-eye-open"></span>查看</a>
								</td>
							</tr><?php endforeach; endif; ?>
					</table>
				</div>
			</div>
		</div>
		<!-- 修改模态框 -->
		<div class="modal fade" id="editCategory" tabindex="-1" role="dialog" aria-labelledby="editCategory">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="myModalLabel">修改分类</h4>
					</div>
					<div class="modal-body">
						<div class="alert alert-warning" role="alert" id="editAlertMsg" style="display: none;"></div>
						<form action="javascript:;" id="edit_category_form">
							<input type="hidden" value="" name="category_id" id="category_id" />
							<div class="form-group">
								<label for="InputCategory">当前分类名</label>
								<input type="text" class="form-control" name="category_name" id="category_name" placeholder="分类名" required>
								<small style="color:#888888;">
								文章分类的名称
							</small>
							</div>
							<div class="form-group">
								<label for="InputFather">当前父类</label>
								<br />
								<select name="category_pid" id="category_pid" class="form-control">
									<option value="0">顶级分类</option>
									<?php if(is_array($trees)): foreach($trees as $key=>$tree): ?><option value="<?php echo ($tree["category_id"]); ?>"><?php echo ($tree["_name"]); ?></option><?php endforeach; endif; ?>
								</select>
								<small style="color:#888888;">
								指定当前分类的父级分类
							</small>
							</div>

							<button type="submit" class="btn btn-primary" id="editCategoryBtn"><span class="glyphicon glyphicon-ok"></span>修改分类</button>
						</form>
					</div>
				</div>
			</div>
		</div>
		<!--修改模态框结束-->
		<!--删除模态框开始-->
		<div class="modal fade bs-example-modal-sm" id="delModalBox" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-sm">
				<div class="panel panel-default">
					<div class="panel-heading"><strong>你确定要删除吗?</strong></div>
					<div class="panel-body">
						<p class="text-success">提示：您确定要删除 (<strong id="category_title">php</strong>)分类吗?</p>
						<p class="text-danger">注意：如果要删除一个分类。那么要确保该分类不存在子分类和文章。否则无法删除</p>
					</div>
					<div class="panel-footer text-center">
						<a href="javascript:;" class="btn btn-danger delCategory"><span class="glyphicon glyphicon-remove"></span>删除</a>
						<a href="javascript:;" class="btn btn-info cleanDelCategory"><span class="glyphicon glyphicon-off"></span>我点错了</a>
					</div>
				</div>
				<div class="alert alert-warning" role="alert" style="display: none;"></div>
			</div>
		</div>
		<!--删除模态框结束-->
		</div>
		
		<div class="col-md-12 text-center" style="margin-top:10px;">
	<div class="alert alert-success" style="background:#DDDDDD;color:#333;">
		CopyRight 2015 Powered By Laiwenbang Email:375500819@qq.com
	</div>
</div>
		<script type="text/javascript">
			 //检测当前分类是否已存在地址
			var checkCategory = "<?php echo U('checkCategory');?>";
			 //修改分类URl地址
			var editCategory = "<?php echo U('editCategory');?>";
			 //删除分类URL地址
			var delCategory  = "<?php echo U('delCategory');?>";
		</script>
		<script type="text/javascript" src="/Blog/Public/js/jquery.js"></script>
		<script type="text/javascript" src="/Blog/Public/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="/Blog/Public/js/category.js"></script>
		<script type="text/javascript" src="/Blog/Public/js/table_search.js">
		</script>
	</body>

</html>